package cn.demomaster.quickui_sample.ui.activity;

import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import cn.demomaster.quickui.annotation.ActivityPager;
import cn.demomaster.quickui.annotation.ResType;
import cn.demomaster.quickui_sample.R;
import cn.demomaster.quickui.view.tabmenu.TabMenuPopupWindow;
import com.demomaster.quickcompat.widget.radiobutton.MyRadioGroup;

@ActivityPager(name = "Tab菜单", preViewClass = TextView.class, resType = ResType.Custome)
public class TabMenuActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_menu);

        //数据初始化
        String[] aaa = new String[30];
        for (int i = 0; i < aaa.length; i++) {
            aaa[i] = "aaa" + (i < 10 ? "---" : "****#####a");
        }
        String[] bbb = new String[20];
        for (int i = 0; i < bbb.length; i++) {
            bbb[i] = "bbb" + (i < 10 ? "---" : "****#####bbbbbbbbbb");
        }
        String[] ccc = new String[120];
        for (int i = 0; i < ccc.length; i++) {
            ccc[i] = "ccc" + (i < 10 ? "---" : "****#####c");
        }
        List<Integer> selectData_a = new ArrayList<>();
        selectData_a.add(1);
        List<Integer> selectData_b = new ArrayList<>();
        selectData_b.add(2);
        selectData_b.add(3);
        List<Integer> selectData_c = new ArrayList<>();
        selectData_c.add(4);
        selectData_c.add(7);
        //单选 多选 多列

        //添加自定义布局
//        TabMenuModel tabMenuModel3 = new TabMenuModel("自定义", R.layout.layout_date_picker2, root -> {
//            LoopView2 loopView2 = root.findViewById(R.id.loop_view2);
//            loopView2.setLoopListener(item -> QdToast.show(mContext, "item=" + item));
//            loopView2.setTextSize(16);//must be called before setDateList
//            loopView2.setDataList(getList(20));
//            loopView2.setCurrentIndex(10);
//        });
//        tabSelectModels.add(tabMenuModel3);

        //组建初始化
       // tabMenuLayout = findViewById(R.id.tab_menu_layout);
       // tabMenuLayout.setTabDividerResId(R.layout.activity_layout_driver);
//        tabMenuLayout.setData(tabSelectModels, (tabButton, tabIndex, position) -> {
//            QdToast.show(mContext, "" + tabIndex + ":" + position);
//            tabMenuLayout.getPopupWindow().dismiss();
//            return null;
//        });
        MyRadioGroup myRadioGroup = findViewById(R.id.ll_tab);
        myRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                TabMenuPopupWindow.Builder builder = new TabMenuPopupWindow.Builder(mContext)
                        .setContentView(cn.demomaster.quickui.R.layout.quick_layout_tab_menu_popup);
                TabMenuPopupWindow quickPopup = builder.create();
                quickPopup.showAsDropDown(findViewById(checkedId));
            }
        });

    }

    public ArrayList<String> getList(int c) {
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < c; i++) {
            list.add("DAY TEST:" + i);
        }
        return list;
    }

}
